package aes

import (
	"encoding/base64"
	"encoding/hex"
)

type Way string

const (
	Base64 Way = "Base64"
	Hex    Way = "Hex"
	Origin Way = "" // 不编码，直接输出字节结果
)

func Encode(value []byte, way Way) []byte {
	switch way {
	case Base64:
		return []byte(base64.StdEncoding.EncodeToString(value))
	case Hex:
		return []byte(hex.EncodeToString(value))
	case Origin:
		return value
	}
	return value
}

func Decode(value []byte, way Way) ([]byte, error) {
	switch way {
	case Base64:
		return base64.StdEncoding.DecodeString(string(value))
	case Hex:
		return hex.DecodeString(string(value))
	case Origin:
		return value, nil
	}
	return value, nil
}
